//
//  searchStockTableViewCell.swift
//  股票框架
//
//  Created by 李小骥 on 2017/9/29.
//  Copyright © 2017年 李小骥. All rights reserved.
//

import UIKit
import SnapKit
enum CustomButtonState:String{
    case plus = "+"
    case minus = "-"
}
class CustomButton:UIButton{
    var status:CustomButtonState!
    var code:String!
}
class SearchStockTableViewCell: UITableViewCell {
    var codeLabel:UILabel!
    var nameLabel:UILabel!
    var pinyinLabel:UILabel!
    var rightButton:CustomButton!
    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
    }
    
    
    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)
        
        // Configure the view for the selected state
    }
    override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        codeLabel = UILabel(frame: CGRect(x: 20, y: 10, width: 50, height: 30))
        nameLabel = UILabel(frame: CGRect(x: 90, y: 10, width: 50, height: 30))
        pinyinLabel = UILabel(frame: CGRect(x: 160, y: 10, width: 50, height: 30))
        rightButton = CustomButton(frame: CGRect(x: 230, y: 10, width: 50, height: 30))
        contentView.addSubview(codeLabel)
        contentView.addSubview(nameLabel)
        contentView.addSubview(pinyinLabel)
        contentView.addSubview(rightButton)
        setLabelsAndRightButton()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    override func layoutSubviews() {
        super.layoutSubviews()
    }
    func setLabelsAndRightButton(){
        codeLabel.snp.makeConstraints { (make) in
            make.left.equalTo(20)
            make.width.equalTo(70)
            make.top.equalTo(15)
        }
        nameLabel.snp.makeConstraints { (make) in
            make.left.equalTo(codeLabel.snp.right).offset(15)
            make.width.equalTo(codeLabel.snp.width)
            make.top.equalTo(codeLabel.snp.top)
        }
        pinyinLabel.snp.makeConstraints { (make) in
            make.left.equalTo(nameLabel.snp.right).offset(15)
            make.width.equalTo(codeLabel.snp.width)
            make.top.equalTo(codeLabel.snp.top)
        }
        rightButton.snp.makeConstraints { (make) in
//            make.right.equalTo(-20)
            make.left.equalTo(pinyinLabel.snp.right).offset(15)
            make.width.equalTo(25)
            make.height.equalTo(rightButton.snp.width)
            make.top.equalTo(codeLabel.snp.top)
        }
    }
}
